<?php

namespace App\Http\Controllers;

use App\Traits\Admin\DashboardViewShareDataTrait;
use Illuminate\Http\Request;
use Spatie\Permission\Models\Role;

class RoleController extends Controller
{
    use DashboardViewShareDataTrait;

    public function index(?string $module = null)
    {
        $this->shareData();
        return view('admin.role.index', [
            'title' => '角色管理',
            'activeModule' => 'core',
            'activeMenu' => 'core.roles',
            'roles' => Role::orderBy('id', 'desc')->paginate(2),
        ])->fragmentIf(request()->hasHeader('HX-Request'), 'content');
    }

    public function delete(\Spatie\Permission\Models\Role $role)
    {
        $role->delete();
    }
}
